import { defHttp, jsonHttp } from '@/utils/http/axios';
import {
  chatidParams,
  deptListParams,
  deptUserListParams,
  integralListParams,
  rankingListParams,
} from './model/deptModel';
import { BasicListResult, BasicDataResult } from '../model/baseModel';

import { ErrorMessageMode } from '#/axios';

enum Api {
  //Login = '/login',
  orderList = '/jz/sys/order/orderList',
  cancel = '/jz/sys/order/cancel',
  detail = '/jz/sys/order/detail',
  editConsigneeInfo = '/jz/sys/order/editConsigneeInfo',
  mark = '/jz/sys/order/mark',
  orderItemList = '/jz/sys/order/orderItemList',
  sendOutGoods = '/jz/sys/order/sendOutGoods',
  sysCreateOrder = '/jz/sys/order/sysCreateOrder',
  viewDvy = '/jz/sys/order/viewDvy',
  getUserInfoByUserId = '/jz/sys/order/getUserInfoByUserId',
  delivery = '/jz/common/delivery',

  refund = '/jz/sys/order/refund', //后台退款
  queryFollowTrace = '/jz/sys/order/queryFollowTrace', //查询运单状态
}

/**
 * @description: user login api
 */
export function orderListApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.orderList,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function cancelApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.cancel,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function detailApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.detail,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 修改收货人信息
 * @param params
 * @param mode
 */
export function editConsigneeInfoApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.editConsigneeInfo,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 修改订单备注
 * @param params
 * @param mode
 */
export function markApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.mark,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 修改子项
 * @param params
 * @param mode
 */
export function orderItemListApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.orderItemList,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 发货
 * @param params
 * @param mode
 */

export function sendOutGoodsApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.sendOutGoods,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 物流详情
 * @param params
 * @param mode
 */
export function viewDvyApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.viewDvy,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function getUserInfoByUserIdApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.getUserInfoByUserId,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 物流公司列表
 */

export function getDeliveryApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.delivery,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function sysCreateOrderApi(params: any, mode: ErrorMessageMode = 'modal') {
  return jsonHttp.post<BasicDataResult>(
    {
      url: Api.sysCreateOrder,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * 后台退款
 */
export function refundApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.refund,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * 查询运单状态
 */
export function queryFollowTraceApi(params: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.queryFollowTrace,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
